package cn.cnf.mapper;

import cn.cnf.entity.Novel;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;
import java.util.List;

/**
 * (novel)数据Mapper
 *
 * @author ZhuMeiYi
 * @description
 * @since 2020-12-04 15:18:43
 */
@Mapper
public interface NovelMapper extends BaseMapper<Novel> {

    IPage<Novel> selectVerifyingList(Page<Novel> page);

    @Update("update novel set subscribe_num = (subscribe_num + #{number}) where novel.id = #{subscribeId}")
    Integer updateSubscribe(@Param("subscribeId") String subscribeId, @Param("number") int number);

    List<Novel> getRecentlyUpdate(Page<Novel> page);

    @Update("update novel set income = #{income} where novel.id = #{novelId}")
    Integer updateIncome(@Param("novelId") String novelId, @Param("income") BigDecimal income);

    @Update("update novel set recommend = #{value} where novel.id = #{novelId}")
    Integer updateRecommend(String novelId, Integer value);

    @Update("update novel set verify_state = #{value} where novel.id = #{novelId}")
    Integer updateVerify(String novelId, Integer value);

    @Update("update novel set collect_num = #{value} where novel.id = #{novelId}")
    Integer updateCollectNum(@Param("novelId") String novelId, @Param("value") Integer value);

    @Update("update novel set comment_num = #{value} where novel.id = #{novelId}")
    Integer updateCommentNum(@Param("novelId") String novelId, @Param("value") Integer value);

    @Update("update novel set state = #{state} where novel.id = #{novelId}")
    Integer updateState(String novelId, Integer state);
}
